package com.yx.frame.builder;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

import com.yx.frame.builder.xml.JavaMethodContentXml;

public class JavaContent extends Composite {
	private Text className;
	private Text methodName;
	private Label lblNewLabel_1;

	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public JavaContent(Composite parent, int style) {
		super(parent, style);
		setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.NORMAL));

		Label lblJava = new Label(this, SWT.NONE);
		lblJava.setBounds(12, 39, 75, 17);
		lblJava.setText("Java类名称：");

		className = new Text(this, SWT.BORDER);
		className.setBounds(92, 36, 473, 23);

		Label lblNewLabel = new Label(this, SWT.NONE);
		lblNewLabel.setBounds(12, 69, 75, 17);
		lblNewLabel.setText("静态方法名：");

		methodName = new Text(this, SWT.BORDER);
		methodName.setBounds(92, 66, 292, 23);

		lblNewLabel_1 = new Label(this, SWT.WRAP);
		lblNewLabel_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
		lblNewLabel_1.setFont(SWTResourceManager
				.getFont("微软雅黑", 10, SWT.NORMAL));
		lblNewLabel_1.setBounds(12, 118, 553, 110);
		lblNewLabel_1
				.setText("    注意：方法必须声明成静态类型，返回类型为ServiceResult，传入参数第一个必须为User，其他参数自定义，只支持JSONArray和String两种类型，例如：public static ServiceResult testMethod(User user,JSONArray country,String country_id )throws Exception{}");

	}

	public void setJavaMethodContentXml(
			JavaMethodContentXml javaMethodContentXml) {
		className.setText(javaMethodContentXml.getClassname());
		methodName.setText(javaMethodContentXml.getStaticMethodName());
	}

	public JavaMethodContentXml getJavaMethodContentXml() {
		JavaMethodContentXml javaMethodContentXml = new JavaMethodContentXml();
		javaMethodContentXml.setClassname(className.getText().trim());
		javaMethodContentXml.setStaticMethodName(methodName.getText().trim());
		return javaMethodContentXml;
	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

}
